home *** CD-ROM | disk | FTP | other *** search
/ Aminet 33 / Aminet 33 - October 1999.iso / Aminet / dev / c / SetMousePort.lha / SetMousePort / SetMousePort.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1999-07-14  |  935 b   |  42 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. #include <exec/types.h>
  5. #include <devices/input.h>
  6.  
  7. #include <clib/exec_protos.h>
  8. #include <clib/alib_protos.h>
  9.  
  10. void main(int argc, char** argv)
  11. {
  12.     puts("Set the Mouseport, ©1999 Point Design Software, Jürgen Schober");
  13.     puts("USAGE: SetMousePort [0|1] (Default = 0)");
  14.  
  15.     BYTE port = 0;
  16.  
  17.     if (argc > 1) port = atoi(argv[1]);
  18.  
  19.     MsgPort  *Iport = CreatePort(NULL,NULL);
  20.     if (Iport)
  21.     {
  22.         IOStdReq *IOreq = (IOStdReq*)CreateExtIO(Iport,sizeof(IOStdReq));
  23.         if (IOreq)
  24.         {
  25.             if (!OpenDevice("input.device",NULL,(IORequest*)IOreq,NULL))
  26.             {
  27.                 printf("Setting Mouse to Port %d\n",port);
  28.                 IOreq->io_Data = &port;
  29.                 IOreq->io_Flags = IOF_QUICK;
  30.                 IOreq->io_Length = 1;
  31.                 IOreq->io_Command = IND_SETMPORT;
  32.                 BeginIO((IORequest*)IOreq);
  33.  
  34.                 if (IOreq->io_Error) printf("Failed!\n");
  35.  
  36.                 CloseDevice((IORequest*)IOreq);
  37.             }
  38.             DeleteExtIO((IORequest*)IOreq);
  39.         }
  40.         DeletePort(Iport);
  41.     }
  42. }